package leetcode.weekly.week339;

import java.util.ArrayList;
import java.util.List;

//Solution2Test
public class Solution2 {

	public List<List<Integer>> findMatrix(int[] nums) {
		List<List<Integer>> ans = new ArrayList<>();
		int[] h = new int[201];
		for (int num : nums) {
			h[num]++;
		}
		while (true) {
			List<Integer> list = new ArrayList<>();
			for (int i = 0; i < h.length; i++) {
				if (h[i] != 0) {
					list.add(i);
					h[i]--;
				}
			}
			if (list.size() == 0) {
				return ans;
			}
			ans.add(list);
		}
	}

}
